#ifndef LINKED_LIST_H
#define LINKED_LIST_H

#include <iostream>

class Node
{
public:
	Node(int data, Node *next=0) : data(data), next(next) {}
	int data;
	Node *next;
};

class ListIterator
{
	friend std::ostream &operator <<(std::ostream &os, const ListIterator &array);
public:
	ListIterator(Node *current) :
      current(current)
   {
   }

	int &operator *()
   {
      return current->data;
   }

	ListIterator operator ++()
   {
      current = current->next;
      return *this;
   }
   
	bool operator ==(const ListIterator &other) {return current == other.current;} 
	bool operator !=(const ListIterator &other) {return !(*this == other);}
private:
	Node *current;
};

class LinkedList {
	friend std::ostream &operator <<(std::ostream &os, const LinkedList &linkedList);
public:
	LinkedList();
	void insert(int value);
	ListIterator begin() { return ListIterator(head);}
	ListIterator end() {return ListIterator(0);}
private:
	Node *head;
};

#endif